<template>
  <div class="app-container">
    <loading v-show="loading"></loading>
    <el-card class="box-card searchFormStyle" style="margin-bottom:1%;">
      <div slot="header" class="clearfix">
        <span>考核周期操作</span>
      </div>
      <div class="text item">
        <el-form ref="searchData" :model="searchData" label-width="130px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="考核周期名称">
                <el-input v-model="searchData.assessmenCycle"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <el-form-item>
                <el-button type="primary" 
                icon="el-icon-plus"
                v-if="permissionHandle('partyBranchCircle:openDialog')"
                 @click="openDialog">新 增</el-button>
                <el-button type="primary" 
                icon="el-icon-search" 
                v-if="permissionHandle('partyBranchCircle:getList')"
                @click="getList">查 询</el-button>
                <el-button type="primary" 
                icon="el-icon-search" 
                v-if="permissionHandle('partyBranchCircle:getList')"
                @click="resetSearch">重 置</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-card>
    <el-card class="box-card" style="margin-bottom:1%;">
        <div slot="header" class="clearfix">
          <span>考核周期列表</span>
        </div>
        <el-table
        :data="tableData"
        border
        ref="tableData"
        style="width: 100%;margin-bottom:1%;"
        >
        <el-table-column
          label="考核周期名称"
          width="180">
          <template slot-scope="scope">
              {{ scope.row.assessmenCycle }}
          </template>
        </el-table-column>
        <el-table-column
          label="考核开始时间"
        >
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.assessmenBeginTime }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="考核结束时间"
        >
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.assessmenEndTime }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="考核周期状态"
          width="180">
          <template slot-scope="scope">
              {{ scope.row.releaseState }}
          </template>
        </el-table-column>
        <el-table-column
          label="创建日期"
          width="180"
        >
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            <span style="margin-left: 10px">{{ scope.row.createTime }}</span>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="380px">
          <template slot-scope="scope">
            <el-button
              size="mini"
              icon="el-icon-document"
              v-if="permissionHandle('partyBranchCircle:handleDetails')"
              @click="handleDetail(scope.$index, scope.row)">详情</el-button>
              <el-button
              size="mini"
              v-if="scope.row.releaseState ==='已计算' "
              icon="el-icon-document"
              @click="lookcalculate(scope.$index, scope.row) && permissionHandle('partyBranchCircle:handleResult')">计算结果查看</el-button>
            <el-button
              size="mini"
              icon="el-icon-document"
              v-if="scope.row.releaseState ==='已发布'&& permissionHandle('partyBranchCircle:comment')"
              @click="selfReported(scope.$index, scope.row)">自查自评</el-button>
            <el-button
              size="mini"
              icon="el-icon-document"
              v-if="scope.row.releaseState ==='已发布' && permissionHandle('partyBranchCircle:Assessment')"
              @click="nextReported(scope.$index, scope.row)">考核</el-button>
            <el-button
              size="mini"
              icon="el-icon-document"
              v-if="scope.row.releaseState ==='已发布' && permissionHandle('partyBranchCircle:count')"
              @click="calculate(scope.$index, scope.row)">计算</el-button>
            <el-button
              size="mini"
              icon="el-icon-printer"
              v-if="scope.row.releaseState ==='待发布' && permissionHandle('partyBranchCircle:count')"
              @click="pushData(scope.$index, scope.row)">发布</el-button>
            <el-button
              size="mini"
              icon="el-icon-edit-outline"
              v-if="scope.row.releaseState ==='待发布'"
              @click="handleEdit(scope.$index, scope.row)">修改</el-button>
            <el-button
              size="mini"
              icon="el-icon-delete"
              type="danger"
              v-if="scope.row.releaseState ==='待发布'"
              @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" :paginations="paginations"></pagination>
    </el-card>
    <el-dialog  fullscreen :title="dialogTitle" :visible.sync="dialogFormVisible" width="90%">
      <el-card class="box-card" style="margin-bottom:1%;">
        <div slot="header" class="clearfix">
          <span>考核周期基本信息</span>
        </div>
        <el-form ref="addBaseData"  :rules="rules" :model="addBaseData" label-width="140px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="考核周期名称" prop="assessmenCycle">
                <el-input v-model="addBaseData.assessmenCycle"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="考核周期起始时间" prop="assessmenBeginTime">
                <el-date-picker
                  v-model="SeTime"
                  type="daterange"
                  value-format="yyyy-MM-dd"
                  range-separator="-"
                  @change="getDates"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>
      <el-card class="box-card padding" style="margin-bottom:1%;">
        <div slot="header" class="clearfix">
          <span>考核指标信息</span>
          <span style="margin-left: 20px">当前分行党支部考核指标总分值：<em class="num" :style="Num>100 ? 'color:red' : 'color:#409eff'">{{Num}}</em></span>
          <span style="margin-left: 20px">当前机关党支部考核指标总分值：<em class="num" :style="partyNum>100 ? 'color:red' : 'color:#409eff'">{{partyNum}}</em></span>
          <div class="btn-box">
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-edit-outline"
              @click="addSearchCondition" style="margin-right:20px">新增指标</el-button>
              <el-button  type="primary"  icon="el-icon-plus"    @click="submitForm" :disabled="disabled">保 存</el-button>
          </div>
        </div>
        <el-row  class="addRow"  :gutter="20">
          <el-col :span="4"  align="center">
              <span style="color:#f56c6c">*</span>指标类型
          </el-col>
          <el-col :span="4" align="center">
              <span style="color:#f56c6c">*</span>党组织类别
          </el-col>
          <el-col :span="10"  align="center">
              <span style="color:#f56c6c">*</span>考核指标
          </el-col>
          <el-col :span="2"  align="center">
            <span style="color:#f56c6c">*</span>指标权重
          </el-col>
          <el-col :span="2"  align="center">
            <span style="color:#f56c6c">*</span>排序编号
          </el-col>
        </el-row>
        <el-row  v-for="(item,index) in liList" :key="item.id" class="addRow"  :gutter="20">
          <el-form  :rules="rules"  :model="liList[index]" :ref="liList[index]">
            <el-col :span="4">
              <el-form-item prop="ndexTypeKey">
                <el-select v-model="liList[index].ndexTypeKey" placeholder="请选择指标类型" class="tree-select">
                  <el-option
                    v-for="item in dzbIndexType"
                    :key="item.ndexTypeKey"
                    :label="item.typeName"
                    :value="item.ndexTypeKey">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item  prop="partyOrgType">
                <el-select v-model="liList[index].partyOrgType" placeholder="请选择党组织类别" @change="getNum" class="tree-select">
                  <el-option
                    v-for="item in partyOrgType"
                    :key="item.paramValue"
                    :label="item.paramName"
                    :value="item.paramValue">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item  prop="jgIndexName" >
                <el-input type="textarea" v-model="liList[index].jgIndexName" placeholder="请输入考核指标名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="2">
              <el-form-item  prop="weights">
                <el-input v-model="liList[index].weights" @keyup.native="getNum($event)"  placeholder="请输入权重分值"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="2">
              <el-form-item  prop="sortNumber">
                <el-input v-model="liList[index].sortNumber" placeholder="请输入排序序号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="2" align="left">
              <el-button
                size="mini"
                icon="el-icon-delete"
                type="danger"
                @click="removeSearchCondition(index)" class="delBtns">删除</el-button>
            </el-col>
          </el-form>
          </el-row>
      </el-card>
    </el-dialog>
    <el-dialog  fullscreen :title="dialogTitle" :visible.sync="detailVisible" width="90%">
      <el-card class="box-card" style="margin-bottom:1%;">
        <div slot="header" class="clearfix">
          <span>考核周期基本信息</span>
        </div>
        <el-form ref="addBaseData"  :rules="rules" :model="addBaseData" label-width="140px" class="detailStyle">
          <el-row>
            <el-col :span="12">
              <span class="labelSpan">
                考核周期名称:
              </span>
              <span class="valueSpan">{{addBaseData.assessmenCycle}}</span>
            </el-col>
            <el-col :span="12">
              <span class="labelSpan">考核周期起始时间: </span>
              <span class="valueSpan">{{addBaseData.assessmenBeginTime}} -- {{addBaseData.assessmenEndTime}}</span>
            </el-col>
          </el-row>
        </el-form>
      </el-card>
      <el-card class="box-card" style="margin-bottom:1%;">
        <div slot="header" class="clearfix">
          <span>考核指标信息</span>
          <span style="margin-left: 20px">当前分行党支部考核指标总分值：<em class="num" :style="Num>100 ? 'color:red' : 'color:#409eff'">{{Num}}</em></span>
          <span style="margin-left: 20px">当前机关党支部考核指标总分值：<em class="num" :style="partyNum>100 ? 'color:red' : 'color:#409eff'">{{partyNum}}</em></span>
        </div>
        <el-table
          :data="detailDatas"
          border
          ref="tableData"
          style="width: 100%;margin-bottom:1%;"
          >
          <el-table-column
            label="党组织类别"
          >
            <template slot-scope="scope">
                <el-select v-model="scope.row.partyOrgType" disabled placeholder="请选择党组织类别" class="tree-select">
                  <el-option
                    v-for="item in partyOrgType"
                    :key="item.paramValue"
                    :label="item.paramName"
                    :value="item.paramValue">
                  </el-option>
                </el-select>
            </template>
          </el-table-column>
          <el-table-column
            label="指标类型"
            width="180">
            <template slot-scope="scope">
               <el-select v-model="scope.row.ndexTypeKey" disabled placeholder="请选择指标类型" class="tree-select">
                  <el-option
                    v-for="item in dzbIndexType"
                    :key="item.ndexTypeKey"
                    :label="item.typeName"
                    :value="item.ndexTypeKey">
                  </el-option>
                </el-select>
            </template>
          </el-table-column>
          <el-table-column
            label="考核指标名称"
          >
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.jgIndexName }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="权重"
          >
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.weights }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="序号"
            width="180">
            <template slot-scope="scope">
                {{ scope.row.sortNumber }}
            </template>
          </el-table-column>
        </el-table>
      </el-card>
    </el-dialog>
    <el-dialog fullscreen title="计算结果详细" :visible.sync="calculateDetail" width="90%">
          <el-table
          :data="calculateData"
          border
          ref="calculateData"
          style="width: 100%;margin-bottom:1%;"
          >
          <el-table-column
            label="考核周期名称"
            width="180">
            <template slot-scope="scope">
                {{ scope.row.yearAssessmenKey }}
            </template>
          </el-table-column>
          <el-table-column
            label="党组织名称"
            width="180">
            <template slot-scope="scope">
                {{ scope.row.partyOrgKey }}
            </template>
          </el-table-column>
          
          <el-table-column
            label="党组织类别"
            width="100">
            <template slot-scope="scope">
                {{ scope.row.partyOrgType }}
            </template>
          </el-table-column>
          <el-table-column
            label="自查自评得分"
           >
            <template slot-scope="scope">
                {{ scope.row.score }}
            </template>
          </el-table-column>
          <el-table-column
            label="上级党组织考核得分"
          >
            <template slot-scope="scope">
                {{ scope.row.sjdzkhScore }}
            </template>
          </el-table-column>
          <el-table-column
            label="满意度测评总人数"
           >
            <template slot-scope="scope">
                {{ scope.row.mydcpZrs }}
            </template>
          </el-table-column>
          <el-table-column
            label="满意度测评得分"
            width="120">
            <template slot-scope="scope">
                {{ scope.row.mydcpScore }}
            </template>
          </el-table-column>
          
          <el-table-column
            label="奖励考核得分"
           >
            <template slot-scope="scope">
                {{ scope.row.jlkhScore }}
            </template>
          </el-table-column>
          <el-table-column
            label="综合得分"
          >
            <template slot-scope="scope">
                {{ scope.row.totalScore }}
            </template>
          </el-table-column>
          <el-table-column
            label="考核档次"
           >
            <template slot-scope="scope">
                {{ scope.row.grade }}
            </template>
          </el-table-column>
          
          <el-table-column
            label="创建日期"
            width="180px"
          >
            <template slot-scope="scope">
              <i class="el-icon-time"></i>
              <span style="margin-left: 10px">{{ scope.row.createTime }}</span>
            </template>
          </el-table-column>
        </el-table>
    </el-dialog>
  </div>
</template>
<script>
import Loading from '@/components/loading/loading'
import pagination from '@/components/pagination/index'
import { getExamCircle, deleteExamCircle, addCircleSearch, savsBranchCircle, detailBranchCircle, pushBranchCircle, setCalculate, lookCalculate } from '@/api/partyBranch/partyBranchCircle'
import { isvalidNumber, isvalidRequire } from '@/utils/validate'
// 非空
var validateRequire = (rule, value, callback) => {
  if (!isvalidRequire(value)) {
    callback(new Error('请输入必填项'))
  } else {
    callback()
  }
}
// 数字验证
var validNumber = (rule, value, callback) => {
  if (!isvalidNumber(value)) {
    callback(new Error('只能输入大于0的数字'))
  } else {
    callback()
  }
}
export default {
  components: {
    Loading,
    pagination
  },
  data() {
    this.permissionHandle = this.$permissionHandle
    return {
      paginations: {
        totalNum: 0,
        currentPage: 1,
        pageSize: 10
      },
      searchData: {
        assessmenCycle: '',
        pageSize: '10',
        pageNum: '1'
      },
      loading: false,
      dialogTitle: '',
      tableData: [],
      dialogFormVisible: false, // 新增弹出框状态
      detailVisible: false,
      calculateDetail: false,
      deleteDepArry: {
        cycleAssessmenKey: ''
      },
      // 列表所选数据集合
      multipleSelection: [],
      SeTime: [],
      addBaseData: {
        cycleAssessmenKey: '',
        assessmenCycle: '',
        assessmenBeginTime: '',
        assessmenEndTime: '',
        data: {
          dexHistoryArray: []
        }
      },
      ifDisabled: false,
      addCircleSearchData: [],
      dzbIndexType: [],
      partyOrgType: [],
      dzbIndexHistory: [],
      liList: [],
      rules: {
        assessmenCycle: [
          { required: true, message: '请输入考核周期名称' },
          { message: '数据不能包含特殊字符', validator: validateRequire },
          { min: 1, max: 31, message: '长度在 1 到 31 个字', trigger: 'blur' }
        ],
        assessmenBeginTime: [
          { required: true, message: '请选择考核起止时间', trigger: 'blur' }
        ],
        ndexTypeKey: [
          { required: true, message: '请选择指标类型', trigger: 'change' }
        ],
        jgIndexName: [
          { required: true, message: '请输入考核指标名称' },
          { message: '数据不能包含特殊字符', validator: validateRequire }
        ],
        partyOrgType: [
          { required: true, message: '请选择党组织类别', trigger: 'change' }
        ],
        sortNumber: [
          { required: true, message: '请输入考核排序序号' },
          { type: 'number', validator: validNumber }
        ],
        weights: [
          { required: true, message: '请输入考核权重分值' },
          { type: 'number', validator: validNumber }
        ]
      },
      validateFlag: false,
      changeFlag: false,
      detailDatas: [],
      Num: 0,
      partyNum: 0,
      disabled: false,
      total: {},
      calculateData: []
    }
  },
  created() {
    this.getList()
    this.getNum()
  },
  watch: {
    dialogFormVisible: function() {
      if (!this.dialogFormVisible) {
        this.addBaseData = {
          cycleAssessmenKey: '',
          assessmenCycle: '',
          assessmenBeginTime: '',
          assessmenEndTime: '',
          data: {
            dexHistoryArray: []
          }
        }
        this.SeTime = []
        this.resetForm()
      }
    }
  },
  methods: {
    getDates(val) {
      if (val !== null) {
        this.addBaseData.assessmenBeginTime = this.SeTime[0]
        this.addBaseData.assessmenEndTime = this.SeTime[1]
      } else {
        this.addBaseData.assessmenBeginTime = ''
        this.addBaseData.assessmenEndTime = ''
      }
    },
    resetSearch() {
      this.searchData.assessmenCycle = ''
      this.getList()
    },
    getNum(e) {
      this.Num = 0
      this.partyNum = 0
      for (var index in this.liList) {
        if (this.liList[index].partyOrgType === '005') {
          this.Num += Number(this.liList[index].weights)
        }
        if (this.liList[index].partyOrgType === '002') {
          this.partyNum += Number(this.liList[index].weights)
        }
      }
      if (this.Num > this.total.branchTotalScore) {
        this.$message({
          showClose: true,
          message: '分行党支部考核总权重不能超过' + this.total.branchTotalScore + '分，否则数据保存错误',
          type: 'warning'
        })
      }
      if (this.partyNum > this.total.organTotalScore) {
        this.$message({
          showClose: true,
          message: '机关党支部考核总权重值不能超过' + this.total.organTotalScore + '分，否则数据保存错误',
          type: 'warning'
        })
      }

      if (this.partyNum > 100 || this.Num > 100) {
        this.disabled = true
      } else {
        this.disabled = false
      }
    },
    blurSearch() {
      this.getList()
    },
    openDialog() {
      this.Num = 0
      this.partyNum = 0
      this.dialogFormVisible = true
      this.dialogTitle = '新增考核周期'
      this.searchData.assessmenCycle = ''
      this.getCircleDetail()
    },
    // 新增获取数据
    getCircleDetail() {
      addCircleSearch(this.deleteDepArry).then(response => {
        // console.log(this.SearchDep)
        this.liList = []
        this.total = response.data.totalScore
        this.addBaseData.data.dexHistoryArray = []
        this.dzbIndexType = response.data.dzbIndexType
        this.partyOrgType = response.data.partyOrgType
        this.releaseState = response.data.releaseState
        this.dzbIndexHistory = response.data.dzbIndexHistory
        this.dzbIndexHistory.forEach(element => {
          this.liList.push({
            cycleAssessmenKey: element.cycleAssessmenKey,
            ndexTypeKey: element.ndexTypeKey,
            partyOrgType: element.partyOrgType,
            jgIndexName: element.jgIndexName,
            sortNumber: parseInt(element.sortNumber),
            weights: parseInt(element.weights)
          })
        })
        this.getNum()
        this.loading = false
      }).catch(error => {
        this.loading = false
        console.log(error)
      })
    },
    // 修改获取详细
    changeCircle() {
      detailBranchCircle(this.deleteDepArry).then(response => {
        // console.log(this.SearchDep)
        this.liList = []
        this.total = response.data.totalScore
        this.addBaseData.data.dexHistoryArray = []
        this.dzbIndexHistory = []
        this.addBaseData.assessmenCycle = response.data.entity.assessmenCycle
        this.SeTime = [response.data.entity.assessmenBeginTime, response.data.entity.assessmenEndTime]
        this.addBaseData.assessmenEndTime = response.data.entity.assessmenEndTime
        this.addBaseData.assessmenBeginTime = response.data.entity.assessmenBeginTime
        this.addBaseData.cycleAssessmenKey = response.data.entity.cycleAssessmenKey
        this.dzbIndexType = response.data.dzbIndexType
        this.partyOrgType = response.data.partyOrgType
        this.releaseState = response.data.releaseState
        this.dzbIndexHistory = response.data.dzbIndexHistory
        this.detailDatas = response.data.dzbIndexHistory
        this.dzbIndexHistory.forEach(element => {
          this.liList.push({
            cycleAssessmenKey: element.cycleAssessmenKey,
            ndexTypeKey: element.ndexTypeKey,
            partyOrgType: element.partyOrgType,
            jgIndexName: element.jgIndexName,
            sortNumber: parseInt(element.sortNumber),
            weights: parseInt(element.weights)
          })
        })
        this.getNum()
        this.loading = false
      }).catch(error => {
        this.loading = false
        console.log(error)
      })
    },
    getList() {
      this.searchData.pageNum = 1
      this.getCircleList()
      this.paginations.currentPage = 1
    },
    // 获取周期列表
    getCircleList() {
      this.loading = true
      return new Promise((resolve, reject) => {
        getExamCircle(this.searchData).then(response => {
          // console.log(this.SearchDep)
          this.tableData = response.data.items
          this.paginations.totalNum = parseInt(response.data.itemsTotalCount)
          resolve()
          this.loading = false
        }).catch(error => {
          this.loading = false
          reject(error)
        })
      })
    },
    // 删除
    deleteExam() {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        return new Promise((resolve, reject) => {
          deleteExamCircle(this.deleteDepArry).then(response => {
            resolve()
            this.loading = false
            this.getList()
            this.deleteDepArry.cycleAssessmenKey = ''
          }).catch(error => {
            this.loading = false
            this.deleteDepArry.cycleAssessmenKey = ''
            reject(error)
          })
        })
      }).catch(() => {
        this.deleteDepArry.cycleAssessmenKey = ''
        this.$refs.tableData.clearSelection()
        return
      })
    },
    // 保存新增考核周期
    saveCircle() {
      console.log(1)
      this.liList.forEach(element => {
        this.addBaseData.data.dexHistoryArray.push(element)
      })
      this.loading = true
      this.addBaseData.data = JSON.stringify(this.addBaseData.data)
      savsBranchCircle(this.addBaseData).then(response => {
        // console.log(this.SearchDep)
        this.loading = false
        this.dialogFormVisible = false
        this.addBaseData.data = {
          dexHistoryArray: []
        }
        this.getList()
      }).catch(error => {
        this.addBaseData.data = JSON.parse(this.addBaseData.data)
        this.loading = false
        console.log(error)
      })
    },
    handleEdit(index, row) {
      this.Num = 0
      this.partyNum = 0
      this.dialogFormVisible = true
      this.dialogTitle = '考核周期修改'
      this.addBaseData.data.dexHistoryArray = []
      this.deleteDepArry.cycleAssessmenKey = row.cycleAssessmenKey
      this.changeCircle()
    },
    // 发布
    pushData(index, row) {
      this.deleteDepArry.cycleAssessmenKey = row.cycleAssessmenKey
      pushBranchCircle(this.deleteDepArry).then(response => {
        this.loading = false
        this.getList()
        this.deleteDepArry.cycleAssessmenKey = ''
      }).catch(error => {
        this.loading = false
        this.deleteDepArry.cycleAssessmenKey = ''
        console.log(error)
      })
    },
    handleDetail(index, row) {
      this.detailVisible = true
      this.dialogTitle = '考核周期详情'
      this.deleteDepArry.cycleAssessmenKey = row.cycleAssessmenKey
      this.changeCircle()
    },

    // 删除事件
    handleDelete(index, row) {
      this.$refs.tableData.clearSelection()
      this.deleteDepArry.cycleAssessmenKey = row.cycleAssessmenKey
      this.deleteExam()
    },
    // 改变分页的时候查询数据
    handleSizeChange(val) {
      this.searchData.pageSize = val
      this.getCircleList()
    },
    handleCurrentChange(val) {
      this.searchData.pageNum = val
      this.getCircleList()
    },
    // 搜索里面的添加搜索项
    addSearchCondition() {
      this.liList.unshift({
        cycleAssessmenKey: '',
        ndexTypeKey: '',
        partyOrgType: '',
        jgIndexName: '',
        sortNumber: '',
        weights: ''
      })
    },
    removeSearchCondition(index) { // 搜索里面的删除搜索项
      this.liList.splice(index, 1)
      this.getNum()
    },
    validateAddForm() {
      console.log(this.$refs[Object()])
      if (this.$refs[Object()] !== undefined) {
        if (this.$refs[Object()].length !== 0) {
          for (const index in this.$refs[Object()]) {
            this.$refs[Object()][index].validate((valid) => {
              if (valid) {
              // this.saveCircle()
                this.validateFlag = true
              } else {
                this.validateFlag = false
              }
            })
            if (!this.validateFlag) {
              break
            }
          }
          if (this.validateFlag) {
            this.saveCircle()
          }
        } else {
          this.saveCircle()
        }
      } else {
        this.saveCircle()
      }
    },
    submitForm() {
      this.addBaseData.data.dexHistoryArray = []
      this.$refs['addBaseData'].validate((valid) => {
        if (valid) {
          this.validateAddForm()
        } else {
          this.validateFlag = false
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm() {
    // this.dialogFormVisible = false
      if (this.$refs[Object()]) {
        this.$refs[Object()].forEach(element => {
          element.resetFields()
        })
      }
      this.$refs['addBaseData'].resetFields()
    },
    selfReported(index, row) {
      this.$router.push({
        path: 'selfReported',
        name: '自查自评',
        query: {
          cycleAssessmenKey: row.cycleAssessmenKey
        }
      })
    },
    nextReported(index, row) {
      this.$router.push({
        path: 'nextReportedList',
        name: '下级考核列表',
        query: {
          cycleAssessmenKey: row.cycleAssessmenKey
        }
      })
    },
    calculate(index, row) {
      this.deleteDepArry.cycleAssessmenKey = row.cycleAssessmenKey
      setCalculate(this.deleteDepArry).then(response => {
        this.loading = false
        this.getList()
        this.deleteDepArry.cycleAssessmenKey = ''
      }).catch(error => {
        this.loading = false
        this.deleteDepArry.cycleAssessmenKey = ''
        console.log(error)
      })
    },
    lookcalculate(index, row) {
      this.deleteDepArry.cycleAssessmenKey = row.cycleAssessmenKey
      lookCalculate(this.deleteDepArry).then(response => {
        this.loading = false
        this.calculateDetail = true
        this.calculateData = response.data
        this.deleteDepArry.cycleAssessmenKey = ''
      }).catch(error => {
        this.loading = false
        this.deleteDepArry.cycleAssessmenKey = ''
        console.log(error)
      })
    }
  }
}
</script>
<style lang="scss" scoped>
 .tree-select,.el-date-editor{width: 95%;}
 .el-input{width: 95%;}
 .delBtns{position: relative;left:20%;top:5px;}
.num{font-size: 18px;font-style: normal;font-weight: 700;}
.padding .el-card__header div{position: relative;}
  .padding .el-card__header .btn-box{position: absolute;right:0;top:50%;transform: translate(0 ,-50%)}


</style>



